#!/usr/bin/env bash
set -e

[[ -z "$1" ]] && echo 'Enter path of project to create. Example: ./optimize-core ./app' && exit 255
[[ ! -e "$1" ]] && echo "Cant find project dir $1. Use ./create-app $1" && exit 255

core_file=$1/app/core.php
echo "Optimizing $core_file"
tmp_file=$(mktemp)
php -r 'echo php_strip_whitespace("'"$core_file"'");' > "$tmp_file"
mv "$tmp_file" "$core_file"
echo '...done'

